<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //resolve方法
        let p1=Promise.resolve(198);//成功
        console.log(p1);
        /* let p2=Promise.resolve(new Promise((resolve,reject)=>{//失败
            reject('err');
        }));
        p2.catch(reason=>{
            console.log(reason);
        }) */
        //reject方法
        /* let p3=Promise.reject(198);//只能返回失败对象
        console.log(p3);
        let p4=Promise.reject(new Promise((resolve,reject)=>{//失败
            resolve('abc');
        }));
        console.log(p4); */
        //all方法
        let p5=Promise.resolve(12);
        let p6=Promise.resolve('ac');
        const result1=Promise.all([p5,p6]);
        console.log(result1);
        //race方法
        let result2=Promise.race([p5,p6]);
        console.log(result2);
    </script>
</body>
</html>